package il.ac.braude.sona.gui.infogui;

import il.ac.braude.sona.constants.Resources;

import java.awt.Component;
import java.awt.Insets;

import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
/**
 * The InfoPanel contains all methods for creating information panel and fill it with rows or titles
 *  
 * @author Ofek Ron
 * @author Avihay Avitan
 * @author Nitzan Inbar
 * @author Sasha Rozenthal
 */
public class InfoPanel extends JPanel {

	/**
	 * Constructs the InfoPanel.
	 * Sets the layout and border of this panel
	 */
	public InfoPanel() {
		setLayout(new BoxLayout(this,BoxLayout.Y_AXIS));
		this.setBorder(new EmptyBorder(new Insets(10, 10, 10, 10)));
	}
	/**
	 * Adding information row to the panel
	 * @param label - the row label
	 * @param value - the row information to display
	 */
	public void addInfoRow(String label, String value) {
		InfoRow row = new InfoRow();
		row.setInfo(label, value);
		//row.setAlignmentX(CENTER_ALIGNMENT);
		add(row);
	}
	/**
	 * Adding information row to the panel
	 * @param label - the row label
	 * @param value - component to display as information
	 */
	public void addInfoRow(String label, Component value) {
		InfoRow row = new InfoRow();
		row.setInfo(label, value);
		add(row);
	}
	
	/**
	 * adding title with underline to the form
	 * 
	 * @param title - the title to add to the formPanel
	 */
	public void addTitleWithUnderline(String title) {
		JPanel centerTitle=new JPanel();
		JLabel label=new JLabel("<html><u>"+title+"</u></html>");;
		label.setFont(Resources.Futura20);
		centerTitle.add(Box.createHorizontalGlue());
		centerTitle.add(label);
		centerTitle.add(Box.createHorizontalGlue());
		add((centerTitle));
	}
	/**
	 * adding title to the form
	 * 
	 * @param title - the title to add to the formPanel
	 */
	public void addTitle(String title) {
		JPanel centerTitle=new JPanel();
		JLabel label=new JLabel(title);
		label.setFont(Resources.Futura18);
		centerTitle.add(Box.createHorizontalGlue());
		centerTitle.add(label);
		centerTitle.add(Box.createHorizontalGlue());
		add((centerTitle));
	}
}
